<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="ISO-8859-1"%>
<%@include file="header.jsp" %><h3>Register a New User</h3>
        
            <%
                      String message = request.getParameter("msg");
                      if (message != null) {
                         out.println("<font color=red>");
                         if ("name".equals(message)) {
                             out.println("Enter a valid name");
                         } else if ("email".equals(message)) {
                             out.println("Enter a valid email address");
                         } else if ("zonenum".equals(message)){
                             out.println("Enter a valid hardiness zone. This is between 0 and 12.");
                         } else if ("password".equals(message)){
                             out.println("enter valid password");
                         } else if ("address".equals(message)){
                             out.println("enter valid address");
                         } else if ("bad".equals(message)){
                             out.println("could not create user");
                         } else if ("pword".equals(message)){
                             out.println("passwords do not match");
                         }
                         out.println("</font>");
                       }
                      
                      
                      String fname="";
                      String email="";
                      String address="";
                      String interests="";
                      if (cookies.length > 0) {
                      for (Cookie cookie : cookies) {
             if (cookie.getName().equals("name")) {
                fname = cookie.getValue();
                 } if(cookie.getName().equals("email")){
                email=cookie.getValue();
                 } if(cookie.getName().equals("address")){
                     address=cookie.getValue();
                 } if(cookie.getName().equals("interests")){
                     interests=cookie.getValue();
                 }
                
            }}
                            %>
        <form action="UserCreateServlet">
            <p><b>Name:</b> <input type="text" name="fname" value="<% out.println(fname); %>" /><br />
            Your real name</p>
            <p><b>Email:</b> <input type="text" name="email" value="<% out.println(email); %>" /><br />
            Your email address. This will be used to log in</p>
            <p><b>Password:</b> <input type="password" name="pword"  /><br />
            Your password</p>
            <p><b>Confirm password:</b> <input type="password" name="pwordconfirm" /></p>
            <p><b>Climate Zone Code:</b> <input type="text" name="zonenum" /><br/>
                Your climate zone, 0 - 12</p>
            <p><b>Address:</b> <input type="text" name="address" value="<% out.println(address); %>" /><br/>
                Your address. This is kept private.</p>
            <p><b>Interests:</b> <input type="text" name="interests" value="<% out.println(interests); %>" /><br/>
                Your interests</p>
            
            <input type="submit" value="register">
        </form>
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<%@include file="footer.html" %>